/**
 * 下移服务接口
 */

//引入Q模块
let Q = require('q');
//引入公共函数
let util = require('../../util');

let index = function(getData, postData, config, _redis, db) {
	let deferred = Q.defer();
	if(postData.funId1 && postData.funId2 && postData.funSid1 && postData.funSid2) {
		db.update('storeFunInfo', {
			funId: postData.funId1
		}, {
			funSid: postData.funSid1
		}).then(function() {
			return db.update('storeFunInfo', {
				funId: postData.funId2
			}, {
				funSid: postData.funSid2
			});
		}, function() {
			//下移服务失败
			deferred.reject('-0212');
		}).then(function() {
			deferred.resolve(1);
		}, function() {
			//下移服务失败
			deferred.reject('-0212');
		});
	}
	else {
		//下移服务接口参数不足
		deferred.reject('-0211');
	}
	return deferred.promise;
}

module.exports = {
	index: index
}